package com.testing.vip14login.controller;

import com.testing.vip14login.model.Person;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname HelloController
 * @Description 类型说明
 * @Date 2023/9/26 21:11
 * @Created by 特斯汀Roy
 */
@RestController
@RequestMapping("/hello")
@Api(tags="欢迎接口集合路径")
public class HelloController {


    @GetMapping
    public String hello() {
        return "你好呀";
    }

    @PostMapping
    public String helloPost(){
        return "你好我是post";
    }

    @GetMapping("/user")
    public String hello(@RequestParam String username){
        return "你好，"+username;
    }

    @PostMapping("/user")
    public String helloPost(@RequestParam String username){
        return "你好我是post，"+username;
    }

    @ApiOperation("传递年龄和名字输出的接口")
    @PostMapping("/age/{sui}")
    public String helloPostAge(@ApiParam("用户名") @RequestParam(required = false) String username,
                               @PathVariable Long sui){
        return String.format("你好，%d岁的%s",sui,username);
    }

    @PostMapping("/setAgeTo0")
    public Person helloPostModel(@RequestBody Person person){
        System.out.println(person);
        person.setAge(0);
        System.out.println(person);
        return person;
    }



}
